import java.util.*;

public class Test33 {









    public static void main02(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] ch=in.nextLine().toCharArray();
        int n=ch.length;
        int[] hash=new int[128];

        int left=0,right=0;
        int count=0;
        int ret=0;
        while(right < n ){
            // 进窗口
            while(hash[ch[right]] == 0 && count<2 ) {
                hash[ch[right]]++;
                count++;
                right++;
            }

            while(hash[ch[right]]++ > 0) right++;


            while( left < right && count > 2 ) {
                if(--hash[ch[left++]] == 0)
                    count--;
            }

            ret=Math.max(ret,right-left);
        }

        System.out.println(ret);
    }







    public static void main01(String[] args) {
        Scanner in = new Scanner(System.in);

        int n =in.nextInt();
        int b=1;
        int ret=0;
        while(n-- != 0){
            ret+=b;
            b=ret;
        }

        System.out.println(ret);

    }
}
